<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>学生-录入就业信息</title>
    <link rel="stylesheet" href="${ctx}/static/layui/css/layui.css">
    <link rel="stylesheet" href="${ctx}/static/css/index.css">
    <style>
        .body-from {
            margin-top: 20px;
        }


        .layui-form-item {
            margin: 8px 0px 8px 40px;
        }

        .layui-form-select dl {
            max-height: 260px;
        }
    </style>
</head>
<body>
<!-- 主体 -->
<div class="body-head"><span>就业信息管理&nbsp;>&nbsp;录入就业信息</span></div>
<form class="body-from layui-form layui-form-pane" id="submit_internship">

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">公司名称</label>
            <div class="layui-input-block" style="width: 300px;">
                <input type="text" name="companyName" id="companyName" class="layui-input"
                       lay-verify="companyName"
                       placeholder="请输入公司名称">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">机构代码</label>
            <div class="layui-input-block" style="width: 300px;">
                <input type="text" name="companyCode" id="companyCode" class="layui-input"
                       lay-verify="companyCode"
                       placeholder="请输入公司代码">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">城市</label>
            <div class="layui-input-block" style="width: 300px;">
                <input type="text" name="city" id="city" class="layui-input" lay-verify="city"
                       placeholder="请输入单位所在城市(例：广州市)">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">详细地址</label>
            <div class="layui-input-block" style="width: 300px">
                <input type="text" name="address" id="address" class="layui-input" lay-verify="address"
                       placeholder="请输入公司详细地址">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">岗位</label>
            <div class="layui-input-block" style="width: 300px">
                <input type="text" name="station" id="station" class="layui-input" lay-verify="station"
                       placeholder="请输入就职岗位">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">部门</label>
            <div class="layui-input-block" style="width: 300px">
                <input type="text" name="department" id="department" class="layui-input" lay-verify="department"
                       placeholder="请输入所在部门(例：研发部)">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">入职日期</label>
            <div class="layui-input-block" style="width: 300px">
                <input type="text" name="entryTime" id="entryTime" autocomplete="off" class="layui-input"
                       lay-verify="entryTime"
                       placeholder="请选择入职日期">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">出勤时间</label>
            <div class="layui-input-inline" style="width: 200px;">
                <input type="text" name="attendanceTime" id="attendanceTime" placeholder="上班时间"
                       lay-verify="attendanceTime"
                       autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid">-</div>
            <div class="layui-input-inline" style="width: 200px;">
                <input type="text" name="closingTime" id="closingTime" placeholder="下班时间" autocomplete="off"
                       lay-verify="closingTime"
                       class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">月薪</label>
            <div class="layui-input-block" style="width: 300px">
                <input type="text" name="salary" id="salary" autocomplete="off" class="layui-input"
                       lay-verify="salary"
                       placeholder="请输入月薪(例：8000.00)">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">福利</label>
            <div class="layui-input-block" style="width: 722px">
                <input type="text" name="weal" id="weal" autocomplete="off" class="layui-input"
                       lay-verify="weal"
                       placeholder="请输入福利">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">开发语言</label>
            <div class="layui-input-block" style="width: 300px">
                <select name="developmentLanguage" id="developmentLanguage" lay-verify="required">
                    <option value="">--请选择--</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">数据库</label>
            <div class="layui-input-block" style="width: 300px">
                <select name="dataBase" id="dataBase" lay-verify="required">
                    <option value="">--请选择--</option>
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">主要框架</label>
            <div class="layui-input-block" style="width: 300px">
                <select name="frame" id="frame" lay-verify="required" lay-search="">
                    <option value="">--请选择--</option>
                </select>
            </div>
        </div>
    </div>

    <div class="layui-form-item layui-form-text" style="width: 1257px">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-block">
                    <textarea placeholder="请在此输入您要说的话" name="remark" id="remark" class="layui-textarea"
                              lay-verify="remark"></textarea>
        </div>
    </div>

    <div class="layui-form-item layui-row">
        <div class="layui-col-md-offset5">
            <button class="layui-btn layui-border-black" id="btn" lay-submit="" lay-filter="demo1">提交</button>
            <button class="layui-btn layui-btn-primary layui-border-black" type="reset">重置</button>
        </div>
    </div>
</form>
<script src="${ctx}/static/js/jquery.min.js"></script>
<script src="${ctx}/static/layui/layui.js"></script>
<script src="${ctx}/static/js/index.js"></script>
<script>
    layui.use(['form', 'layer', 'jquery', 'laydate'], function () {
        let form = layui.form
            , $ = layui.$
            , layer = layui.layer
            , laydate = layui.laydate;
        laydate.render({
            elem: '#entryTime'
        });
        laydate.render({
            elem: '#attendanceTime',
            type: 'time'
        });
        laydate.render({
            elem: '#closingTime',
            type: 'time'
        });
        $.ajax({
            type: 'post',
            url: '${ctx}/student/getDevelopmentLanguageList.action',
            success: function (data) {
                //console.log(data.developmentLanguage);
                $.each(data, function (index, value) {
                    //console.log(index+" "+value);
                    $.each(value, function (i, v) {
                        //console.log(v.id+" "+v.developmentLanguage);
                        $("#developmentLanguage").append("<option value='" + v.id + "'>" + v.developmentLanguage + "</option>")
                    });
                });
                form.render();
            }
        });
        $.ajax({
            type: 'post',
            url: '${ctx}/student/getDataBaseList.action',
            success: function (data) {
                //console.log(data.dataBases);
                $.each(data, function (index, value) {
                    $.each(value, function (i, v) {
                        $("#dataBase").append("<option value='" + v.id + "'>" + v.dataBase + "</option>")
                    });
                });
                form.render();
            }
        });
        $.ajax({
            type: 'post',
            url: '${ctx}/student/getFrameList.action',
            success: function (data) {
                $.each(data, function (index, value) {
                    $.each(value, function (i, v) {
                        $("#frame").append("<option value='" + v.id + "'>" + v.frame + "</option>")
                    });
                });
                form.render();
            }
        });
        form.verify({
            companyName: function (value) {
                if (value.length == 0) {
                    return '公司名称项不能为空';
                }
            },
            companyCode: function (value) {
                if (value.length == 0) {
                    return '机构代码项不能为空';
                }
                if (!/^[0-9A-HJ-NPQRTUWXY]{8}-[0-9A-HJ-NPQRTUWXY]$/.test(value)) {
                    return '机构代码项格式不正确';
                }
            },
            station: function (value) {
                if (value.length == 0) {
                    return '岗位项不能为空';
                }
            },
            principalName: function (value) {
                if (value.length == 0) {
                    return '负责人姓名不能为空';
                }
            },
            principalPhone: function (value) {
                if (value.length == 0) {
                    return '负责人电话不能为空';
                }
                console.log(value);
                if (!/^1[3|4|5|7|8][0-9]{9}$/.test(value) && !/^\d{3}-\d{7,8}|\d{4}-\d{7,8}$/.test(value)) {
                    return '负责人电话格式不正确';
                }
            },
            entryTime: function (value) {
                if (value.length == 0) {
                    return '入职日期不能为空';
                }
            },
            salary: function (value) {
                if (value.length == 0) {
                    return '月薪不能为空';
                }
                if (!/^\d+(\.\d+)?$/.test(value)) {
                    return '月薪格式不正确';
                }
            }

        });
        form.on('submit(demo1)', function (data) {
            console.log(data);
            $.ajax({
                type: "post",
                url: "${ctx}/student/addJob.action",
                data: data.field,
                dataType: "json",
                contentType: "application/x-www-form-urlencoded",
                success: function (data) {
                    // console.log(data);
                    if (data.flag) {
                        layer.msg("添加成功");
                    } else {
                        layer.msg("添加失败");
                    }
                },
                error: function () {
                    layer.msg("请求失败");
                }
            });
            layer.closeAll('dialog');
            return false;
        })
    });
</script>
</body>
</html>
